# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

_realname=cloog

pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.18.1
pkgrel=2
groups=("${MINGW_PACKAGE_PREFIX}")
pkgdesc="Library that generates loops for scanning polyhedra"
arch=('any')
url="http://www.bastoul.net/cloog/"
license=('GPL')
depends=("${MINGW_PACKAGE_PREFIX}-isl")
makedepends=("${MINGW_PACKAGE_PREFIX}-isl")
options=('staticlibs')
source=(http://www.bastoul.net/cloog/pages/download/${_realname}-${pkgver}.tar.gz
        'cloog-0.18.1-no-undefined.patch')
md5sums=('e34fca0540d840e5d0f6427e98c92252'
         'b976d088b7fab0471431655f561e679f')

prepare() {
  cd "$srcdir/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/cloog-0.18.1-no-undefined.patch
  
  autoreconf -fi
}

build() {
  cd $srcdir/${_realname}-${pkgver}
  ./configure --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --enable-static \
    --disable-shared \
    --with-isl=system \
    --with-bits=gmp \
    --with-isl-prefix=${MINGW_PREFIX} \
    --with-gmp-prefix=${MINGW_PREFIX} \
    --program-suffix=-isl
  make
}

check() {
  cd $srcdir/${_realname}-${pkgver}
  make check
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  rm -f ${pkgdir}${MINGW_PREFIX}/bin/*.exe
}
